package main.userInterface;

import main.demonutils.io.IslandIOController;
import main.model.hexisland.DefaultHexIsland;
import main.model.hexisland.HexIsland;
import main.userInterface.hexislandui.HexEditorPanel;
import main.userInterface.hexislandui.HexIslandCanvas;
import main.userInterface.hexislandui.HexIslandFrame;
import main.userInterface.ioui.IslandIOToolPanel;

import javax.swing.*;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * User: gabe
 * Date: 02/07/13
 * Time: 19:45
 * To change this template use File | Settings | File Templates.
 */
public class IslandEditorGUI extends JFrame {

    IslandIOController islandIOController = null;

    public IslandEditorGUI(IslandIOController islandIOController){
        super("WALLACE'S ISLAND Critters");

        if(islandIOController != null) this.islandIOController = islandIOController;
        else{
            //HexIsland hexIsland = ;
            this.islandIOController = new IslandIOController(new DefaultHexIsland());
        }

        setSize(900,600);
        setResizable(true);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        HexIslandCanvas hexIslandCanvas = new HexIslandCanvas(this.islandIOController.getIsland());
        HexIslandFrame hexIslandFrame = new HexIslandFrame(hexIslandCanvas);


        JTabbedPane sideBar = new JTabbedPane();
        sideBar.addTab("Island Editor", new HexEditorPanel(this.islandIOController.getIsland() , hexIslandCanvas));
        sideBar.addTab("Save & Load" , new IslandIOToolPanel(this.islandIOController) );

        JPanel sideBarPanel = new JPanel();
        sideBarPanel.setLayout(new BorderLayout());
        sideBarPanel.add(sideBar, BorderLayout.NORTH);


        add(hexIslandFrame, BorderLayout.CENTER);
        add(sideBarPanel, BorderLayout.EAST);

        this.add(hexIslandFrame);
        //House Keeping
        //validateTree();
        //pack();
        setVisible(true);
        toFront();
    }


    public static void main(String args[]) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        IslandEditorGUI thegui = new IslandEditorGUI(null);
    }
}
